package cn.yunhe.insurance.controller;


import cn.yunhe.insurance.dao.ComboDao;
import cn.yunhe.insurance.entity.Branch;
import cn.yunhe.insurance.entity.Case;
import cn.yunhe.insurance.entity.Order;
import cn.yunhe.insurance.service.CheckService;
import cn.yunhe.insurance.service.InsurcateService;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author李仕龙
 */
@RestController
@RequestMapping("/check")
public class CheckController {
    @Resource
    private CheckService checkService;

    @Resource
    private InsurcateService insurcateService;
    @Resource
    private ComboDao comboDao;

    //处理报案入口============================================================================
    @RequestMapping("/checkCase")
    public ModelAndView checkCase(){
        ModelAndView mv=new ModelAndView("checkCase");
        return mv;
    }
    @RequestMapping("/getCasePage")
    public Map queryLikeCase(int pageSize,int pageNum,String key){
        Map map=new HashMap();
        map.put("pageSize",pageSize);
        map.put("pageNum",pageNum);
        map.put("key",key);
        Page page=checkService.queryLikeCase(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        return map;
    }

    @RequestMapping("/changeCaseState")
    public String changeCaseState(Case c){
        Boolean b=checkService.changeCaseState(c);
        if (b){
            return "true";
        }else{
            return "false";
        }
    }

    //审核支点入口========================================================================
    @RequestMapping("/checkBranch")
    public ModelAndView checkBranch(){
        ModelAndView mv=new ModelAndView("checkBranch");
        return mv;
    }
    @RequestMapping("/changeBranchState")
    public String changeBranchState(Branch b){
        Boolean bb=checkService.changeBranchState(b);
        if (bb){
            return "true";
        }else {
            return "false";
        }
    }


    //审核退保入口======================================================================
    @RequestMapping("/checkBackOrder")
    public ModelAndView checkBackOrder(){
        ModelAndView mv=new ModelAndView("checkBackOrder");
        return mv;
    }

    @RequestMapping("/getBackOrder")
    public Map getBackOrder(int pageSize,int pageNum,String str){
        Map map=new HashMap();
        map.put("pageSize",pageSize);
        map.put("pageNum",pageNum);
        map.put("str",str);
        Page page=checkService.getBackOrder(map);
        map.put("page",page);
        map.put("totalPage",page.getPages());
        return map;
    }

    @RequestMapping("/changeOrderState")
    public String changeOrderState(Order o){
        Boolean b=checkService.changeOrderState(o);
        if (b){
            return "true";
        }else{
            return "false";
        }
    }

    //保险类别审核入口========================================================
    @RequestMapping("/checkInsurcate")
    public ModelAndView checkInsurcate(){
        return new ModelAndView("checkInsurcate");
    }

    @RequestMapping("/adoptInsurcate")
    public boolean adoptInsurcate(@RequestParam String iuuid) {
        return insurcateService.adoptInsurcate(iuuid);
    }
    @RequestMapping("/refuseInsurcate")
    public boolean refuseInsurcate(@RequestParam String iuuid) {
        return insurcateService.refuseInsurcate(iuuid);
    }

    //保险套餐审核入口=====================================
    @RequestMapping("/checkCombo")
    public ModelAndView checkCombo(){
        return new ModelAndView("checkCombo");
    }

    @RequestMapping("/adoptCombo")
    public boolean adoptCombo(String comuuid){
        return comboDao.adoptCombo(comuuid);
    }

    @RequestMapping("/refuseCombo")
    public boolean refuseCombo(String comuuid){
        return comboDao.refuseCombo(comuuid);
    }


    public InsurcateService getInsurcateService() {
        return insurcateService;
    }

    public void setInsurcateService(InsurcateService insurcateService) {
        this.insurcateService = insurcateService;
    }

    public CheckService getCheckService() {
        return checkService;
    }

    public void setCheckService(CheckService checkService) {
        this.checkService = checkService;
    }

    public ComboDao getComboDao() {
        return comboDao;
    }

    public void setComboDao(ComboDao comboDao) {
        this.comboDao = comboDao;
    }
}
